﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sinacor.Servico.Bovespa.ResumoFinanceiro.Service.ServiceImplementation.Translator.BusinessEntityToDataContract
{
    public class FinanceiroPendente
    {
        #region Construtor

        /// <summary>
        /// Construtor padrão
        /// </summary>
        public FinanceiroPendente()
        {
        }

        #endregion

        #region Metodos

        /// <summary>
        /// ToFinanceiroPendenteResponse
        /// </summary>
        /// <param name="from"></param>
        /// <returns></returns>
        public DataContract.Response.FinanceiroPendenteResponse ToFinanceiroPendenteResponse(BusinessEntity.FinanceiroPendente from)
        {
            if (from == null) return null;

            return new Sinacor.Servico.Bovespa.ResumoFinanceiro.Service.DataContract.Response.FinanceiroPendenteResponse
            {
                ApelidoBroker = from.ApelidoBroker,
                ApelidoCliente = from.ApelidoCliente,
                BolsaFaturamento = from.BolsaFaturamento,
                CodigoBroker = from.CodigoBroker,
                CodigoCliente = from.CodigoCliente,
                DataLiquidacao = from.DataLiquidacao,
                DataPregao = from.DataPregao,
                DataUltimaAlocacao = from.DataUltimaAlocacao,
                DataUltimaAtualizacao = from.DataUltimaAtualizacao,
                IndicadorBroker = (DataContract.Enum.TipoCliente)from.IndicadorBroker,
                LiquidacaoNota = from.LiquidacaoNota
            };
        }

        /// <summary>
        /// ToFinanceiroPendenteResponse
        /// </summary>
        /// <param name="from"></param>
        /// <returns></returns>
        public List<DataContract.Response.FinanceiroPendenteResponse> ToFinanceiroPendenteResponse(List<BusinessEntity.FinanceiroPendente> from)
        {
            List<DataContract.Response.FinanceiroPendenteResponse> retorno = new List<DataContract.Response.FinanceiroPendenteResponse>();

            if (from == null) return null;

            from.ForEach(
                delegate(BusinessEntity.FinanceiroPendente item)
                {
                    retorno.Add(this.ToFinanceiroPendenteResponse(item));
                });

            return retorno;
        }

        #endregion
    }
}
